package org.syncsoft.overalt.communication.api;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.syncsoft.overalt.common.api.Configuration;

/**
 * 
 * @author tptfc
 *
 */
public class ServerUrl {
	private static Properties properties;
	
	static {
		try {
			setProperties(new Properties());
			InputStream stream = Configuration.class.getClassLoader().getResourceAsStream("serverURIs.properties");
			getProperties().load(stream);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 
	 * @return
	 */
	public static String getKeepAlive() {
		return getUrl(getProperty("overalt.keepALive"));
	}
	
	/**
	 * @return get file URL
	 */
	public static String getFile() {
		return getUrl(getProperty("overalt.getFile"));
	}
	
	/**
	 * @return delete file URL
	 */
	public static String deleteFile() {
		return getUrl(getProperty("overalt.deleteFile"));
	}
	
	/**
	 * 
	 * @return
	 */
	public static String createFile() {
		return getUrl(getProperty("overalt.createFile"));
	}
	
	/**
	 * 
	 * @return
	 */
	public static String commitFile() {
		return getUrl(getProperty("overalt.commitFile"));
	}
	
	/**
	 * 
	 * @return
	 */
	public static String getHome() {
		return getUrl(getProperty("overalt.home"));
	}
	
	/**
	 * 
	 * @return
	 */
	public static String getDocument() {
		return getUrl(getProperty("overalt.getDocument"));
	}

	/**
	 * 
	 * @return
	 */
	public static String getUserCommunities() {
		return getUrl(getProperty("overalt.getUserCommunities"));
	}

	/**
	 * 
	 * @return
	 */
	public static String getUserContacts() {
		return getUrl(getProperty("overalt.getUserContacts"));
	}
	
	/**
	 * 
	 * @return
	 */
	public static String getCommunityMebers() {
		return getUrl(getProperty("overalt.getCommunityMembers"));
	}
	
	/**
	 * 
	 * @return
	 */
	public static String getCommunityFiles() {
		return getUrl(getProperty("overalt.getCommunityFiles"));
	}
	
	/**
	 * 
	 * @return
	 */
	public static String getUserFiles() {
		return getUrl(getProperty("overalt.getUserFiles"));
	}
	
	/**
	 * 
	 * @return
	 */
	public static String getPolicySettingsService() {
		return getUrl(getProperty("overalt.getPolicySettingsService"));
	}
	
	
	

	/**
	 * 
	 * @param propertyName
	 * @return
	 */
	private static String getProperty(String propertyName) {
		return getProperties().getProperty(propertyName);
	}
	
	/**
	 * 
	 * @param uri
	 * @return server domain + uri
	 */
	private static String getUrl(String uri) {
		return Configuration.getUrlDomain() + uri;
	}

	//	GETs AND SETs
	protected static Properties getProperties() {
		return properties;
	}

	protected static void setProperties(Properties properties) {
		ServerUrl.properties = properties;
	}
}
